﻿<%@ Page Language="C#" MasterPageFile="~/YUIAspNet.Master" AutoEventWireup="true" CodeBehind="ButtonTypeCheckbox.aspx.cs" Inherits="YUIAspNetDemo.Button.ButtonTypeCheckbox" Title="Untitled Page" %>

<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="server">
    <title>YUIAsp.Net Controls : LiveDemo : Button : Checkbox Button</title>
    <script type="text/javascript">
        function CheckDependencies(sender, args)
        {
            //if asp.net is already checked, no checking is required
            if(!$find('<%= chkYUIAspNet.ClientID %>').get_YUIControl().get("checked"))
                return;
            
            var yuichecked = $find('<%= chkYUI.ClientID %>').get_YUIControl().get("checked");
            var aspnetajaxchecked = $find('<%= chkAspNetAjax.ClientID %>').get_YUIControl().get("checked");
            
            //check is YUI and ASP.NET Ajax are checked.
            if(!yuichecked || !aspnetajaxchecked)
            {
                //uncheck first
                $find('<%= chkYUIAspNet.ClientID %>').get_YUIControl().set("checked", false);
                
                //confirm selection
                $find('<%= confirm.ClientID %>').show();
            }
        }
        
        function CheckBoth(sender, args)
        {
            $find('<%= chkYUI.ClientID %>').get_YUIControl().set("checked", true);
            $find('<%= chkAspNetAjax.ClientID %>').get_YUIControl().set("checked", true);
            $find('<%= chkYUIAspNet.ClientID %>').get_YUIControl().set("checked", true);
            
            sender.hide();
        }
        
        function Cancel(sender, args)
        {
            sender.hide();        
        }
        
    </script>
    
</asp:Content>

<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="server">
    <h1>Checkbox button</h1>
    
    <p>Below is an example of the ASP.NET Button used as a checkbox. With it's rich client API, it's the perfect replacement for the classic ASP.NET Checkbox control.</p>
    
    <p>
        <asp:Panel GroupingText="JS Frameworks" ID="pnl" runat="server">
        <br />
            <yui:Button runat="server" Text="YUI" Value="yui" ID="chkYUI" ButtonType="Checkbox"></yui:Button>
            <yui:Button runat="server" Text="MooTools" Value="MT" ID="chkMooTools" ButtonType="Checkbox"></yui:Button>
            <yui:Button runat="server" Text="Script.aculo.us" ID="chkScriptaculous" ButtonType="Checkbox"></yui:Button>
            <yui:Button runat="server" Text="ASP.NET Ajax" ID="chkAspNetAjax" ButtonType="Checkbox"></yui:Button>
            <yui:Button runat="server" Text="YUIAsp.NET" OnClientClick="CheckDependencies" ID="chkYUIAspNet" ButtonType="Checkbox"></yui:Button>
            <br /><br />
        </asp:Panel>
    </p>
    
    <p>
        <yui:Button ID="btn" runat="server" Text="Get checkboxes state" /><br />
        <asp:Label ID="lblState" runat="server"></asp:Label>
    </p>
    
    <yui:SimpleDialog ID="confirm" runat="server" Centered="true" Modal="true" Width="350px" Height="100px" Closeable="false">
        <HeaderTemplate>Check?</HeaderTemplate>
        <TextTemplate>
        YUI and ASP.NET Ajax options need to be checked to continue. <br />Check them automatically?
        </TextTemplate>
        <DialogButtonList>
            <yui:DialogButton Text="Check both" IsDefault="true" Handler="CheckBoth" />
            <yui:DialogButton Text="Check none" Handler="Cancel" />
        </DialogButtonList>
    </yui:SimpleDialog>
</asp:Content>

